// pages/contacts/details.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lawyerId: "",
    lawyerInfo: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var orgid = wx.getStorageSync('companyId');
    var lawyerId = options.lawyerId;
    this.setData({
      lawyerId: lawyerId
    })
    if (lawyerId != null && lawyerId != "" && lawyerId != "undefiend") {
      // 获取上一个页面
      var pages = getCurrentPages();
      var page = pages[pages.length - 2];
      var lawyerList = page.data.lawyerList;
      for (var lawyer of lawyerList){
        for (var law of lawyer.lawyers){
          if (law.id == lawyerId) {
            var lawyerInfo = {};
            lawyerInfo.userName = law.userName;
            lawyerInfo.phoneNo = law.phoneNo;
            that.setData({
              lawyerInfo: lawyerInfo,
            })
            break;
          }
        }
      }
      // wx.request({
      //   url: getApp().data.servsers + "/statis/lawyerInfo.shtml",
      //   data: {
      //     lawyerId: lawyerId,
      //     orgid: orgid,
      //   },
      //   header: {
      //     'content-type': 'application/json' // 默认值
      //   },
      //   success: function (res) {
      //     //  console.info(res.data);
      //     that.setData({
      //       lawyerInfo: res.data,
      //     })
      //   }
      // })
    }

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  telephone: function (option) {
    var telnumber = option.currentTarget.dataset.telephone;
    wx.makePhoneCall({
      phoneNumber: telnumber
    })
  }
})